package com.gem.service.impl;

import com.gem.mapper.CampusConnMapper;
import com.gem.domain.CampusConn;
import com.gem.service.CampusConnService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @Author: 玲
 * @Description:
 * @create 2019-10-16 14:54
 * @Modified By:
 */
@Service
@SuppressWarnings("all")
@Transactional(rollbackFor=Exception.class)
public class CampusConnServiceImpl implements CampusConnService {

    @Autowired CampusConnMapper mapper;

    @Override
    public Integer save(CampusConn campusConn) {
        campusConn.setCampusConnCreateDate(new Date());
        return mapper.save(campusConn);
    }

    @Override
    public PageInfo<CampusConn> findAll(Integer campusId, int currentPage, int pageSize) {
        PageInfo<CampusConn> pageInfo = null;
        try {
            PageHelper.startPage(currentPage,pageSize);
            pageInfo =new PageInfo<>(mapper.findAll(campusId));
        }catch (Exception e){
            e.printStackTrace();
        }
        return pageInfo;
    }


    @Override
    public CampusConn findById(Integer campusConnId) {
        return mapper.findById(campusConnId);
    }

    @Override
    public Integer deleteById(Integer campusConnId) {
        return mapper.deleteById(campusConnId);
    }

    @Override
    public Integer update(CampusConn campusConn) {
        return mapper.update(campusConn);
    }

    @Override
    public String findCampusName(Integer campusId) {
        return mapper.findCampusName(campusId);
    }

    @Override
    public Integer deleteAll(int[] campusConnIds) {
        Integer result = mapper.deleteAll(campusConnIds);
        return result;
    }

    @Override
    public List<CampusConn> findAllCampusConn(Integer campusId) {
        return mapper.findAll(campusId);
    }

    @Override
    public List<CampusConn> findAllConn() {
        return mapper.findAllConn();
    }

}
